/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.additional;

import com.sun.lwuit.Component;
import com.sun.lwuit.Image;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.list.DefaultListCellRenderer;
import datamodel.Order;

/**
 *
 * @author Kvest
 */
public class CompletedOrderListRenderer extends DefaultListCellRenderer
{
    private static Image cancaledIcon;
    public static void setCancaledIcon(Image cancaledIcon)
    {
        CompletedOrderListRenderer.cancaledIcon = cancaledIcon;
    }
    
    public CompletedOrderListRenderer()
    {
        super(false);
        
        setEndsWith3Points(true);
    }
    
    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected)
    {
        Label element = (Label)super.getListCellRendererComponent(list,value,index,isSelected);
        
        if (value != null && (value instanceof Order))
        {
            element.setText(((Order)value).getShortDescription());
            element.setIcon(((Order)value).getStatus() == Order.STATE_CANCELLED ? cancaledIcon : null);
        }
        
        return element;
    }
}
